//
//  APTranslateModel.m
//  AqualPolo
//
//  Created by dong on 2024/5/10.
//

#import "APTranslateModel.h"

@implementation APTranslations

+ (APTranslations *)modelWithDictionary:(NSDictionary *)dict{
    APTranslations *model = [[APTranslations alloc] init];
    model.translatedText = dict[@"translatedText"];
    model.detectedSourceLanguage = dict[@"detectedSourceLanguage"];
    return model;
}

@end


@implementation APDetectedLanguage

+(APDetectedLanguage *)modelWithDictionary:(NSDictionary *)dict{
    APDetectedLanguage *lan = [[APDetectedLanguage alloc] init];
    lan.language = dict[@"language"];
    lan.score = [dict[@"score"] doubleValue];
    return lan;
}


@end

@implementation APTranslateModel

+ (APTranslateModel *)modelWithDictionary:(NSDictionary *)dict{
    APTranslateModel *model = [[APTranslateModel alloc] init];
    model.detectedLanguage = [APDetectedLanguage modelWithDictionary:dict[@"detectedLanguage"]];
    if (dict[@"translations"]) {
       NSMutableArray *result = [NSMutableArray array];
        for (NSDictionary *e in dict[@"translations"]) {
            APTranslations *m = [APTranslations modelWithDictionary:e];
            [result addObject:m];
        }
        model.translations = result;
    }
    return model;
}

@end
